package com.bdqn.service.impl;

import com.bdqn.mapper.HisSchedulingMapper;
import com.bdqn.mapper.SysDeptMapper;
import com.bdqn.mapper.UserMapper;
import com.bdqn.pojo.HisScheduling;
import com.bdqn.pojo.User;
import com.bdqn.service.HisSchedulingService;
import com.bdqn.service.SysDeptService;
import com.bdqn.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HisSchedulingServiceImpl implements HisSchedulingService {
    @Autowired
    HisSchedulingMapper hisSchedulingMapper;
    @Autowired
    SysDeptMapper sysDeptMapper;
    @Autowired
    UserMapper userMapper;

    //排班分页查询
    @Override
    public PageInfo<HisScheduling> getHisScheduling(int pageNum, int pageSize ,int userId,int deptId) {
        PageHelper.startPage(pageNum,pageSize);
        List<HisScheduling> list=hisSchedulingMapper.getHisScheduling(userId,deptId);
        for (HisScheduling hisScheduling:list){
            hisScheduling.setSysDept(sysDeptMapper.getSysDeptID(hisScheduling.getDeptId()));
        }
        PageInfo<HisScheduling> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<HisScheduling> getScheduleWeekDate(int userId, String subsectionType, String startDate, String endDate) {
        List<HisScheduling> list=hisSchedulingMapper.getScheduleWeekDate(userId,subsectionType,startDate,endDate);
        for (HisScheduling hisScheduling:list){
            hisScheduling.setSysDept(sysDeptMapper.getSysDeptID(hisScheduling.getDeptId()));
        }
        for (HisScheduling hisScheduling:list){
            hisScheduling.setUser(userMapper.getUserDANGE(hisScheduling.getUserId()));
//            hisScheduling.setUser(userMapper.getUserDANGE(hisScheduling.getUserId())
        }
        return list;
    }

    @Override
    public List<HisScheduling> getHisSchedulingPB(int deptId, int subsectionType, int schedulingType,String schedulingDay) {
        List<HisScheduling> list=hisSchedulingMapper.getHisSchedulingPB(deptId,subsectionType,schedulingType,schedulingDay);
        return list;
    }
}
